package my.yuan.dubbo.consumer;

import com.alibaba.dubbo.remoting.TimeoutException;
import com.alibaba.dubbo.rpc.RpcException;
import my.yuan.dubbo.api.DemoInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: zhaoqiyuan
 * @description: TODO
 * @date: 2021/12/13 14:36
 */
@Component
public class DemoConsumer {
    @Autowired
    private DemoInterface demoInterface;

    public String test(String a) {
        try {
            demoInterface.test(a);

        } catch (Exception e) {
            System.out.println("common:" + e);
            System.out.println();
            if (e instanceof RpcException) {
                RpcException exception = (RpcException) e;
                if (exception.isTimeout()) {
                    System.out.println("timeout" + e);
                }


            }
        }
        return "xxx";
    }
}
